package com.biz.primus.homepage.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.List;

import static com.google.common.collect.Lists.newArrayList;

/**
 * Created by defei on 2/11/17.
 */
@Data
@ApiModel("动态数据请求参数")
@AllArgsConstructor
@NoArgsConstructor
public class MethodExecutorMethodParam implements Serializable {

    public static final String JOIN_SYMBOL = ",";

    @ApiModelProperty("请求唯一标识")
    private String identity;

    @ApiModelProperty("多数据标识")
    private List<String> dataIds;

    /**
     * 去除首页本地化参数
     */
    @Deprecated
    private CoverReqVo location;

    @JsonIgnore
    public String getStringIds(){

        return StringUtils.join(dataIds, JOIN_SYMBOL);
    }

    public void setStringDataIds(String dataIdArrayString) {

        this.dataIds = dataIdArrayString != null ? newArrayList(dataIdArrayString.split(JOIN_SYMBOL)) : null;
    }

}
